//
//  WeiboEmotion.m
//  yuikemall
//
//  Created by yuike5 yuike5 on 12-2-22.
//  Copyright (c) 2012年 yuike. All rights reserved.
//
#import "NSString+Extension.h"
#import "WeiboEmotion.h"

@implementation WeiboEmotion
@synthesize phrase;
@synthesize localName;

-(void) dealloc
{
    [phrase release];
    [localName release];
    [super dealloc];
}

-(id) initWithPhrase:(NSString*)phrase_ localName:(NSString*)localName_
{
    self = [super init];
    if (self) {
        self.phrase = phrase_;
        self.localName = localName_;
    }
    return self;
}

-(NSString*) sinaPhrase {
    return [NSString stringWithFormat:@"[%@]", [self phraseContent]];
}
-(NSString*) tencPhrase {
    return [NSString stringWithFormat:@"/%@", [self phraseContent]];
}

-(NSString*) phraseContent {
    if (!phrase || phrase.length==0) {
        return phrase;
    }
    
    NSString* temp = phrase;
    
    // sina
    if ([temp startswith:@"["])
        temp = [temp substringFromIndex:1];
    if ([temp endswith:@"]"]) {
        temp = [temp substringToIndex:temp.length-1];
    }
    
    // tenc
    if ([temp startswith:@"/"])
        temp = [temp substringFromIndex:1];
        
    return temp.strip;
}

@end
